module("NetWork.Action.ComResAction",package.seeall)
local UIWinMgr = require("UI.UIWinMgr").UIWinMgr
local NetCmdActionBase = require("NetWork.Action").NetCmdActionBase

ComResAction = NetCmdActionBase:new()

function ComResAction:Action(bytes)
    local UIWinMgr = require("UI.UIWinMgr").UIWinMgr
    local ComReq = require("Protol.comMessage_pb").ComReq()
    ComReq:ParseFromString(bytes)

    if ComReq.code == 3 then
    	local UIWinMgr = require("UI.UIWinMgr").UIWinMgr
       UIWinMgr:OpenNewGameNotice(ComReq.strParams[1])	
       if #ComReq.params > 0 then
        if ComReq.params[1] == 62 or ComReq.params[1] == 8 then
          local NewGamepaijulistWin = UIWinMgr:GetWindow("NewGamepaijulistWin") 
          if NewGamepaijulistWin ~= nil and NewGamepaijulistWin.myContainerIsOpend then
            --Debug.log("---1111-----")
            NewGamepaijulistWin:OnCreateRoomFlush()
          end
          local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin") 
          if NewGameLoobyWin ~= nil  and  NewGameLoobyWin.N_paizhuoPanle~= nil and NewGameLoobyWin.N_paizhuoPanle.gameObject.activeSelf then
            --Debug.log("---2222-----")
            NewGameLoobyWin:RefreshTables()
          end
          local UIWinMgr = require("UI.UIWinMgr").UIWinMgr
          UIWinMgr:CloseMask()
        end
       end
   	-------收到code56是创建成功
    elseif ComReq.code == 56 then
      Debug.log("----------收到code56是创建成功---------")
      local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")  
      NewGameLoobyWin:RefreshTables()
   	-- 	local NewGamepaijulistWin = UIWinMgr:OpenWindow("NewGamepaijulistWin")	
  		-- NewGamepaijulistWin:OnCreateRoomFlush()
    elseif ComReq.code == 10 then  --钻石更新
      local MainUserData = require("DynamicData.MainUserData").MainUserData
      MainUserData.diamond = MainUserData.diamond + ComReq.params[1]
      local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")  
      NewGameLoobyWin:UpdateUserInfo()
    elseif ComReq.code == 42 then  ---金币更新  变化时推送
      local MainUserData = require("DynamicData.MainUserData").MainUserData
      MainUserData.currentclubgold = ComReq.params[1]
      local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")  
      NewGameLoobyWin:UpdateUserInfo()
      Debug.log("-------------------金币变化-----------"..ComReq.params[1])
    elseif ComReq.code == 17 then  ---通用消息  文字
        UIWinMgr:OpenTextNotice(ComReq.params[1])
    end  
end

require("NetWork.NetCmdSet").CmdSet[5001] = ComResAction --注册处理对象